Bayern Munich earned a nervous 1-0 win at St Pauli thanks to a sensational 28-metre drive from Jamal Musiala to stay unbeaten.
But despite some early close attempts from Uruguay, Japan began to impose themselves on the game and Koji Miyoshi gave them the lead in the 25th minute with a confident finish following a counterattack.
Defending champions Brazil advanced to the quarter-finals of the men's Olympic soccer tournament after a 3-1 victory over Saudi Arabia on Wednesday helped them top Group D, while Ivory Coast booked their berth by sending Germany home.